<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="description" content="API docs for the StreamTransformer constructor from the Class StreamTransformer class from the dart:async library, for the Dart programming language.">
  <title>StreamTransformer constructor - StreamTransformer class - dart:async library - Dart API</title>
  <!-- required because all the links are pseudo-absolute -->
  <base href="../..">

  <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="static-assets/github.css">
  <link rel="stylesheet" href="static-assets/styles.css">
  <link rel="icon" href="static-assets/favicon.png">
  
</head>

<body>

<div id="overlay-under-drawer"></div>

<header id="title">
  <button id="sidenav-left-toggle" type="button">&nbsp;</button>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="index.html">manage_calendar_events</a></li>
    <li><a href="dart-async/dart-async-library.html">dart:async</a></li>
    <li><a href="dart-async/StreamTransformer-class.html">StreamTransformer<span class="signature">&lt;<wbr><span class="type-parameter">S</span>, <span class="type-parameter">T</span>&gt;</span></a></li>
    <li class="self-crumb">StreamTransformer const constructor</li>
  </ol>
  <div class="self-name">StreamTransformer</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<main>

  <div id="dartdoc-sidebar-left" class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left">
    <header id="header-search-sidebar" class="hidden-l">
      <form class="search-sidebar" role="search">
        <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
      </form>
    </header>
    
    <ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
      <li><a href="index.html">manage_calendar_events</a></li>
      <li><a href="dart-async/dart-async-library.html">dart:async</a></li>
      <li><a href="dart-async/StreamTransformer-class.html">StreamTransformer<span class="signature">&lt;<wbr><span class="type-parameter">S</span>, <span class="type-parameter">T</span>&gt;</span></a></li>
      <li class="self-crumb">StreamTransformer const constructor</li>
    </ol>
    
    <h5>StreamTransformer class</h5>
    <ol>
      <li class="section-title"><a href="dart-async/StreamTransformer-class.html#constructors">Constructors</a></li>
      <li><a href="dart-async/StreamTransformer/StreamTransformer.html">StreamTransformer</a></li>
      <li><a href="dart-async/StreamTransformer/StreamTransformer.fromBind.html">fromBind</a></li>
      <li><a href="dart-async/StreamTransformer/StreamTransformer.fromHandlers.html">fromHandlers</a></li>
    
      <li class="section-title inherited">
        <a href="dart-async/StreamTransformer-class.html#instance-properties">Properties</a>
      </li>
      <li class="inherited"><a href="dart-core/Object/hashCode.html">hashCode</a></li>
      <li class="inherited"><a href="dart-core/Object/runtimeType.html">runtimeType</a></li>
    
      <li class="section-title"><a href="dart-async/StreamTransformer-class.html#instance-methods">Methods</a></li>
      <li><a href="dart-async/StreamTransformer/bind.html">bind</a></li>
      <li><a href="dart-async/StreamTransformer/cast.html">cast</a></li>
      <li class="inherited"><a href="dart-core/Object/noSuchMethod.html">noSuchMethod</a></li>
      <li class="inherited"><a href="dart-core/Object/toString.html">toString</a></li>
    
      <li class="section-title inherited"><a href="dart-async/StreamTransformer-class.html#operators">Operators</a></li>
      <li class="inherited"><a href="dart-core/Object/operator_equals.html">operator ==</a></li>
    
    
      <li class="section-title"><a href="dart-async/StreamTransformer-class.html#static-methods">Static methods</a></li>
      <li><a href="dart-async/StreamTransformer/castFrom.html">castFrom</a></li>
    
    </ol>
  </div><!--/.sidebar-offcanvas-left-->

  <div id="dartdoc-main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">
      <div><h1><span class="kind-constructor">StreamTransformer&lt;<wbr><span class="type-parameter">S</span>, <span class="type-parameter">T</span>&gt;</span> constructor</h1></div>

    <section class="multi-line-signature">
      const
      <span class="name ">StreamTransformer&lt;<wbr><span class="type-parameter">S</span>, <span class="type-parameter">T</span>&gt;</span>(<wbr><span class="parameter" id="-param-onListen"><span class="type-annotation"><a href="dart-async/StreamSubscription-class.html">StreamSubscription</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> <span class="parameter-name">onListen</span>(<span class="parameter" id="onListen-param-stream"><span class="type-annotation"><a href="dart-async/Stream-class.html">Stream</a><span class="signature">&lt;<wbr><span class="type-parameter">S</span>&gt;</span></span> <span class="parameter-name">stream</span>, </span> <span class="parameter" id="onListen-param-cancelOnError"><span class="type-annotation"><a href="dart-core/bool-class.html">bool</a></span> <span class="parameter-name">cancelOnError</span></span>)</span>)
    </section>

    <section class="desc markdown">
      <p>Creates a <a href="dart-async/StreamTransformer-class.html">StreamTransformer</a> based on the given <code>onListen</code> callback.</p>
<p>The returned stream transformer uses the provided <code>onListen</code> callback
when a transformed stream is listened to. At that time, the callback
receives the input stream (the one passed to <a href="dart-async/StreamTransformer/bind.html">bind</a>) and a
boolean flag <code>cancelOnError</code> to create a <a href="dart-async/StreamSubscription-class.html">StreamSubscription</a>.</p>
<p>If the transformed stream is a broadcast stream, so is the stream
returned by the <a href="dart-async/StreamTransformer/bind.html">StreamTransformer.bind</a> method by this transformer.</p>
<p>If the transformed stream is listened to multiple times, the <code>onListen</code>
callback is called again for each new <a href="dart-async/Stream/listen.html">Stream.listen</a> call.
This happens whether the stream is a broadcast stream or not,
but the call will usually fail for non-broadcast streams.</p>
<p>The <code>onListen</code> callback does <em>not</em> receive the handlers that were passed
to <a href="dart-async/Stream/listen.html">Stream.listen</a>. These are automatically set after the call to the
<code>onListen</code> callback (using <a href="dart-async/StreamSubscription/onData.html">StreamSubscription.onData</a>,
<a href="dart-async/StreamSubscription/onError.html">StreamSubscription.onError</a> and <a href="dart-async/StreamSubscription/onDone.html">StreamSubscription.onDone</a>).</p>
<p>Most commonly, an <code>onListen</code> callback will first call <a href="dart-async/Stream/listen.html">Stream.listen</a> on
the provided stream (with the corresponding <code>cancelOnError</code> flag), and then
return a new <a href="dart-async/StreamSubscription-class.html">StreamSubscription</a>.</p>
<p>There are two common ways to create a StreamSubscription:</p><ol><li>by allocating a <a href="dart-async/StreamController-class.html">StreamController</a> and to return the result of
listening to its stream. It's important to forward pause, resume and
cancel events (unless the transformer intentionally wants to change
this behavior).</li><li>by creating a new class that implements <a href="dart-async/StreamSubscription-class.html">StreamSubscription</a>.
Note that the subscription should run callbacks in the <a href="dart-async/Zone-class.html">Zone</a> the
stream was listened to (see <a href="dart-async/Zone-class.html">Zone</a> and <a href="dart-async/Zone/bindCallback.html">Zone.bindCallback</a>).</li></ol>
<p>Example:</p>
<pre class="language-dart"><code>/// Starts listening to [input] and duplicates all non-error events.
StreamSubscription&lt;int&gt; _onListen(Stream&lt;int&gt; input, bool cancelOnError) {
  StreamSubscription&lt;String&gt; subscription;
  // Create controller that forwards pause, resume and cancel events.
  var controller = new StreamController&lt;String&gt;(
      onPause: () {
        subscription.pause();
      },
      onResume: () {
        subscription.resume();
      },
      onCancel: () =&gt; subscription.cancel(),
      sync: true); // "sync" is correct here, since events are forwarded.

  // Listen to the provided stream using `cancelOnError`.
  subscription = input.listen((data) {
    // Duplicate the data.
    controller.add(data);
    controller.add(data);
  },
      onError: controller.addError,
      onDone: controller.close,
      cancelOnError: cancelOnError);

  // Return a new [StreamSubscription] by listening to the controller's
  // stream.
  return controller.stream.listen(null);
}

// Instantiate a transformer:
var duplicator = const StreamTransformer&lt;int, int&gt;(_onListen);

// Use as follows:
intStream.transform(duplicator);
</code></pre>
    </section>
    
    <section class="summary source-code" id="source">
      <h2><span>Implementation</span></h2>
      <pre class="language-dart"><code class="language-dart">const factory StreamTransformer(
        StreamSubscription&lt;T&gt; onListen(
            Stream&lt;S&gt; stream, bool cancelOnError)) =
    _StreamSubscriptionTransformer&lt;S, T&gt;;</code></pre>
    </section>

  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-right" class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right">
  </div><!--/.sidebar-offcanvas-->

</main>

<footer>
  <span class="no-break">
    manage_calendar_events 1.0.1
  </span>

  
</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="static-assets/typeahead.bundle.min.js"></script>
<script src="static-assets/highlight.pack.js"></script>
<script src="static-assets/URI.js"></script>
<script src="static-assets/script.js"></script>


</body>

</html>
